home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 11223 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.3 KB  |  44 lines

  1. Newsgroups: comp.lang.c++
  2. Path: howland.reston.ans.net!torn!news!apollo!saed
  3. From: saed@engn.uwindsor.ca (Saed Aryan,13325,1100,g)
  4. Subject: error: undef. but decl. template as member
  5. X-Nntp-Posting-Host: apollo.engn.uwindsor.ca
  6. Message-ID: <Do6owF.LKo@news.uwindsor.ca>
  7. Keywords: template
  8. Sender: news@news.uwindsor.ca (Usenet)
  9. Reply-To: saed@engn.uwindsor.ca
  10. Organization: VLSI Research Group - University of Windsor
  11. Date: Wed, 13 Mar 1996 02:14:38 GMT
  12.  
  13. Hi all,
  14.  
  15. I am curious to know:
  16.  
  17. --- Why is it not sufficient to declare a template in order to be able to
  18.     use it as a member of a class, and then to define the template class later.
  19.  
  20. I would like to know whether this is compiler specific or whether it's a C++
  21. template flaw, since the error does not make logical sense to me. 
  22. The code snippet below shows the problem. If you succeed in compiling this code
  23. errorless, or if you have an explanataion, I'd be glad to know!
  24.  
  25. Thanks a lot,
  26. Aryan.
  27.  
  28. //----cut here
  29. template <class T> class A1{};        // A1 declared and defined
  30. template <class T> class A2;        // A2 just declared
  31.  
  32. class B1 {private: A1<int> a1;};// okay, A1 with template is defined
  33. class B2 {private: A2<int> a2;};// error: field `a2' has incomplete type 
  34.  
  35. template <class T> class A2{};        //A1 now also defined
  36.  
  37. main(){};
  38. //----end code
  39.  
  40.  
  41.  
  42.  
  43.  
  44.